require 'extract/rules/rule'

module Extract
  
  class JSONRule < Rule
    
    def extract source_receiver, dest_receiver
      val = get_json_val source_receiver
      if !val.nil? then
        preproces_val val
        handle_val val, dest_receiver
      end
    end
    
    protected
    
    def get_json_val(doc)
      raise NotImplementedError.new "Subclass must implents this method!!" 
    end
    
    def preproces_val(val)
      val.downcase!
    end
    
    def handle_val(val, dest_receiver)
      raise NotImplementedError.new "Subclass must implents this method!!"
    end
    
  end
  
end